package com.qf.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;

/**
 * @author zjw
 * @description
 * @date 2021/10/8$ 16:27$
 */
public class Number2GenderSerializer extends JsonSerializer<Integer> {

    @Override
    public void serialize(Integer value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        switch (value) {
            case 0:
                gen.writeString("女");
                break;
            case 1:
                gen.writeString("男");
                break;
            default:
                gen.writeString("嬲");
        }
    }
}
